﻿Public Class KhachHangDAO
    Public Shared Sub insert(ByVal kh As KhachHangDTO)
        Dim strsql As String
        strsql = "insert into KHACHHANG(MAKHACHHANG,TENKHACHHHANG,TIENNOKHACHHACH,DIEMTICHLUY,DIENTHOAI) values('" & kh.MaKhachHang & "','" & kh.TenKhachHang & "'," & kh.TienNoKhachHang & "," & kh.DiemTichLuy & ",'" & kh.DienThoai & "')"
        SQLProvider.ExecNoneQuery(strsql)

    End Sub
    Public Shared Function selectall() As DataTable
        Dim strsql As String
        strsql = "select * from KHACHHANG"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strsql)
        Return dt
    End Function
    Public Shared Sub delete(ByVal MaKhachHang As String)
        Dim strsql As String
        strsql = "DELETE FROM KHACHHANG WHERE MAKHACHHANG = '" & MaKhachHang & "'"
        SQLProvider.ExecNoneQuery(strsql)
    End Sub
    Public Shared Sub Update(ByVal kh As KhachHangDTO)
        Dim strSQL As String = "Update KHACHHANG set TENKHACHHHANG = '" & kh.TenKhachHang & "', TIENNOKHACHHACH = '" & kh.TienNoKhachHang & "', DIEMTICHLUY = '" & kh.DiemTichLuy & "', DIENTHOAI = '" & kh.DienThoai & "' where MAKHACHHANG = '" & kh.MaKhachHang & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function TimKiemKhachHangTen(ByVal Tenkh As String) As DataTable
        Dim strsql As String
        strsql = "SELECT * FROM KHACHHANG WHERE TENKHACHHHANG LIKE '" & Tenkh & "%'"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strsql)
        Return dt
    End Function
    Public Shared Function TimKiemKhachHangMa(ByVal MaKh As String) As DataTable
        Dim strsql As String
        strsql = "SELECT * FROM KHACHHANG WHERE MAKHACHHANG = '" & MaKh & "'"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strsql)
        Return dt
    End Function
End Class
